package com.teamone.etl.taskmanager.entity;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

/**
 任务处理排序表(EtlTaskOrderInfo)表实体类

 @author makejava
 @since 2021-01-09 08:46:50 */
@SuppressWarnings("serial")
public class EtlTaskOrderInfo extends Model<EtlTaskOrderInfo> {
    /**
     id
     */
    @TableId(type = IdType.INPUT)
    private String id;
    /**
     节点ID
     */
    private String nodeId;
    /**
     任务ID
     */
    private String taskId;
    /**
     选择节点ID
     */
    private String selectNodeId;
    /**
     选择表名称
     */
    private String selectTableName;
    /**
     选择表字段
     */
    private String selectTableField;
    /**
     创建人
     */
    private String createBy;
    /**
     创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;
    /**
     更新人
     */
    private String updateBy;
    /**
     更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;
    /**
     * 排序类型,1升序,2降序
     * */
    private Integer orderSort;

    public EtlTaskOrderInfo(JSONObject node, Date now) {
        this.id= UUID.randomUUID().toString();
        this.nodeId=node.getString("id");
        JSONObject nodeData = node.getJSONObject("data");
        switch (nodeData.getString("sort")){
            case "1":
            case "ASC":
                this.orderSort=1;
                break;
            case "2":
            case "DESC":
                this.orderSort=2;
                break;
            default:break;
        }
        this.taskId=nodeData.getString("taskId");
        this.selectNodeId=nodeData.getString("selectNodeId");
        this.selectTableName=nodeData.getString("selectTableName");
        this.selectTableField=nodeData.getString("selectTableField");
        this.createTime=this.updateTime= now;
    }

    public Integer getOrderSort() {
        return orderSort;
    }

    public void setOrderSort(Integer orderSort) {
        this.orderSort = orderSort;
    }

    public String getId () {
        return id;
    }

    public void setId (String id) {
        this.id = id;
    }

    public String getNodeId () {
        return nodeId;
    }

    public void setNodeId (String nodeId) {
        this.nodeId = nodeId;
    }

    public String getTaskId () {
        return taskId;
    }

    public void setTaskId (String taskId) {
        this.taskId = taskId;
    }

    public String getSelectNodeId () {
        return selectNodeId;
    }

    public void setSelectNodeId (String selectNodeId) {
        this.selectNodeId = selectNodeId;
    }

    public String getSelectTableName () {
        return selectTableName;
    }

    public void setSelectTableName (String selectTableName) {
        this.selectTableName = selectTableName;
    }

    public String getSelectTableField () {
        return selectTableField;
    }

    public void setSelectTableField (String selectTableField) {
        this.selectTableField = selectTableField;
    }

    public String getCreateBy () {
        return createBy;
    }

    public void setCreateBy (String createBy) {
        this.createBy = createBy;
    }

    public Date getCreateTime () {
        return createTime;
    }

    public void setCreateTime (Date createTime) {
        this.createTime = createTime;
    }

    public String getUpdateBy () {
        return updateBy;
    }

    public void setUpdateBy (String updateBy) {
        this.updateBy = updateBy;
    }

    public Date getUpdateTime () {
        return updateTime;
    }

    public void setUpdateTime (Date updateTime) {
        this.updateTime = updateTime;
    }

    /**
     获取主键值

     @return 主键值
     */
    @Override
    protected Serializable pkVal () {
        return this.id;
    }
}